const state = {
  breadcrumb: [
    // 	{
  //   path: '/',
  //   name: 'home',
  //   cnName: '门户首页',
  //   level: 1
  // }
  ],
  frameLoading: false,
  frameVisible: false,
  frameUrl: '',
  frameBgcolor: '#f3f3f3',
  tabName: 'home',
  frameTabs: [
    // {
    //   title: '门户首页',
    //   name: 'home',
    //   id: 'home',
    //   code: 'home11',
    //   frameNetStatus404: false // frame加载404
    // }
  ],
  operator: ''
};

const actions = {
  setBreadcrumb: ({
    commit
  }, value) => {
    commit('setBreadcrumb', value);
  },
  setFrameVisible: ({
    commit
  }, value) => {
    commit('setFrameVisible', value);
  },
  setFrameLoading: ({
    commit
  }, value) => {
    commit('setFrameLoading', value);
  },
  setFrameUrl: ({
    commit
  }, value) => {
    commit('setFrameUrl', value);
  },
  setFrameBgcolor: ({
    commit
  }, value) => {
    commit('setFrameBgcolor', value);
  },
  setFrameTabsItem: ({
    commit
  }, value) => {
    commit('setFrameTabsItem', value);
  },
  setFrameTabs: ({
    commit
  }, value) => {
    commit('setFrameTabs', value);
  },
  setFrameTabsName: ({
    commit
  }, value) => {
    commit('setFrameTabsName', value);
  }
};

const mutations = {
  setBreadcrumb: (state, value) => {
    state.breadcrumb = value;
  },
  setFrameVisible: (state, value) => {
    state.frameVisible = value;
    const body = document.body;
    if (value) {
      body.style.overflowY = 'hidden';
    } else {
      body.style.overflowY = 'visible';
    }
  },
  setFrameLoading: (state, value) => {
    state.frameLoading = value;
  },
  setFrameUrl: (state, value) => {
    state.frameUrl = value;
  },
  setFrameBgcolor: (state, value) => {
    state.frameBgcolor = value;
  },
  setFrameTabsItem: (state, value) => {
    state.frameTabs[value.index].frameNetStatus404 = value.val;
  },
  setFrameTabs: (state, value) => {
    state.frameTabs = value;
  },
  setFrameTabsName: (state, value) => {
    state.tabName = value;
  },
  setOperator: (state, value) => {
    state.operator = value;
  }
};

export default {
  state,
  actions,
  mutations
};
